# -*- coding: utf-8 -*-
import scrapy
from movie.items import MovieItem


class MeijuSpider(scrapy.Spider):
    name = 'meiju'
    allowed_domains = ['meijutt.com']
    start_urls = ['http://www.meijutt.com/new100.html']

    def parse(self, response):
        # 提取网页ul里面的class为top-list fn-clear部分
        movies = response.xpath('//ul[@class="top-list  fn-clear"]/li')
        # 得到是一个list
        for each_movie in movies:
            # 引入模块 这个模块是在items里面的类
            item = MovieItem()
            # 获取想要存储的信息
            item['name'] = each_movie.xpath('./h5/a/@title').extract()[0]
            print(item)
            # 添加到管道
            yield item
